function getRootPath(){
    var strFullPath=window.document.location.href;
    var strPath=window.document.location.pathname;
    var pos=strFullPath.indexOf(strPath);
    var prePath=strFullPath.substring(0,pos);
    var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
    return(prePath+postPath);
}
var path=getRootPath();

$(function(){
    init()
    $("#notarize").click(function(){
        $("#succeed").show();
        return false;
    });
    $("#img-play").click(function(){
        $("#audio").toggleClass("audio-show")
    })
});

$(function(){
    var  num =0 ;
    $("#img-change").click(function(){
        $("#add").show().addClass("fadeup");
        $(this).addClass("niceIn");
        var img=document.getElementById("img-change");
        num ++;
        if(num<=1){
            //saveSatus('1');//保存点赞状态
            setTimeout(function(){
                $("#poll-num").text(parseFloat($("#poll-num").text())+1).css("color","#f00")
            },700);
            $("#vote-change").text("已投票").css("color","#ff0707");
            img.src="../img/love-chang.png";
            setTimeout(function(){
                $("#add").hide();
            },700);
			 saveSatus('1');//保存点赞状态
        }else{
            $("#poll-num").text(parseFloat($("#poll-num").text()));
            $("#vote-change").text("已投票");
            img.src="../img/love-chang.png";
            $("#add").hide();
        };
    });
    var shareWidth=0.9*($("body").width());
    $("#sharing-show").width(shareWidth);
    $("#sharing").click(function(){
        $("#sharing-show").show().css("top","5%");
        $("#new-share").show();
    });
    $("#cancel,#new-share").click(function(){
            $("#sharing-show").hide();
            $("#new-share").hide();
    })
});
$(function(){
    $("#img-play").click(function(){
        $("#addxuanzhuan").toggleClass("xuanzhuan")
    })
});



 var  anum =0;
function init(){
    var info=$("#acquire").text();
    var timeout = setInterval(function(){
        var  decreasenum =$("#decrease").html();
        decreasenum--;
        $("#decrease").text(decreasenum);
        if(decreasenum==0){
            window.clearInterval(timeout);
            $("#acquire").html("获取验证码").css("background","#ff7f00");
            $("#verify_code").val("");
            $("#acquire").click(function(){
                anum ++;
                if(anum==1){
                    //  sendVerifCode();
                	sendVerifCode();
                    return false
                }else{
                    return false;
                }
            })
        }
    },1000);
}


function  testSendVerifCode(){
    $("#acquire").html("<span id='decrease'>60</span>s后重新获取").css("background","#f00");
    //var decreasenum = document.getElementById("decrease").innerHTML;
    var  decreasenum =$("#decrease").html();
        var timeout = setInterval(function(){
            var  decreasenum =$("#decrease").html();
            decreasenum--;
            $("#decrease").text(decreasenum);
            if(decreasenum==0){
                window.clearInterval(timeout);
                $("#acquire").html("获取验证码").css("background","#ff7f00");
                $("#verify_code").val("");
				 anum=0;
            }
        },1000);
}
function sendVerifCode(){
    var phone=$("#phone").val();
    $.ajax( {
        url : getRootPath()+'/regis/reSend',
        data:{
            mobilephone:phone
        },
        type : 'post', // 数据发送方式
        success : function(result) {
            //$("#acquire").html("<span id='decrease'>60</span>s后重新获取").css("background","#ff0000");
        	testSendVerifCode();
        }
    });
}
